﻿using RayDen.Library.Core.Primitives;

namespace RayDen.Library.Entity.Scene {
    public class MaterialInfo {
        public string Name;
        public RgbSpectrum Ka;
        public RgbSpectrum Kd;
        public RgbSpectrum Ks;
        public RgbSpectrum Kr;
        public RgbSpectrum Kt;
        public RgbSpectrum Ke;
        public float Exponent;

        public TextureInfo Alpha;
        public TextureInfo Diffuse;
        public TextureInfo Specular;
        public TextureInfo NormalMap;
        public TextureInfo BumpMap;
        public MediumInfo MediumInfo;


        public SampledSpectrum Reflectance;
        private RgbSpectrumInfo[] coeffs;
        public RgbSpectrumInfo[] Coefficients
        {
            get
            {
                if (coeffs == null)
                {
                    coeffs = new []
                    {
                        new RgbSpectrumInfo(Ka), 
                        new RgbSpectrumInfo(Kd), 
                        new RgbSpectrumInfo(Ks), 
                        new RgbSpectrumInfo(Kr), 
                        new RgbSpectrumInfo(Kt), 
                        new RgbSpectrumInfo(Ke),
                    };
                }
                return coeffs;
            }
        }

        public string DataFile;


        public string MaterialName
        {
            get { return Name; }
        }

        public MediumInfo MediumData
        {
            get { return this.MediumInfo; }
        }

        public TextureInfo DiffuseTexture
        {
            get { return this.Diffuse; }
            set { this.Diffuse = value; }
        }

        public TextureInfo AlphaTexture
        {
            get { return this.Alpha; }
            set { this.Alpha = value; }

        }

        public TextureInfo BumpTexture
        {
            get { return this.BumpMap; }
            set { this.BumpMap = value; }

        }

        public TextureInfo NormalMapTexture
        {
            get { return this.NormalMap; }
            set { this.NormalMap = value; }

        }

        public RgbSpectrum DiffuseReflectance
        {
            get { return Kd; }
            set { Kd = value; }
        }

        public RgbSpectrum GlossReflectance
        {
            get { return Ks; }
            set { Ks = value; }
        }

        public RgbSpectrum SpecularReflectance
        {
            get { return Kr; }
            set { Kr = value; }
        }

        public float PhongExponent
        {
            get { return Exponent; }
            set { Exponent = value; }
        }

        public RgbSpectrum Emission
        {
            get { return Ke; }
            set { Ke = value; }
        }
    }
}